﻿#include "stdio.h"
#include <string.h>
#include "stdlib.h"
int main(int args, char *argv[]) {
	FILE *fp;
	int numc = 0;
	int numv = 0;
	char c;
	fp = fopen(argv[args - 1], "r");
	if (fp == NULL)
	{
		printf("打开文件失败");
		exit(0);
	}
	if (strcmp(argv[args - 2], "-c") == 0)
	{

		while ((c = fgetc(fp)) != EOF)
		{
			numc++;
		}
		printf("字符：%d", numc);
		fclose(fp);
	}
	else if (strcmp(argv[args - 2], "-w") == 0)
	{
		while ((c = fgetc(fp)) != EOF)
		{
			if (c == ' ')
				numv++;
		}
		printf("单词：%d", numv + 1);
		fclose(fp);
	}
	return 0;
}